home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / glibc108.zip / glibc108 / hurd / hurd.h < prev    next >
C/C++ Source or Header  |  1994-04-27  |  8KB  |  242 lines

  1. /* Copyright (C) 1993, 1994 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3.  
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public License as
  6. published by the Free Software Foundation; either version 2 of the
  7. License, or (at your option) any later version.
  8.  
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. Library General Public License for more details.
  13.  
  14. You should have received a copy of the GNU Library General Public
  15. License along with the GNU C Library; see the file COPYING.LIB.  If
  16. not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  17. Cambridge, MA 02139, USA.  */
  18.  
  19. #ifndef    _HURD_H
  20.  
  21. #define    _HURD_H    1
  22. #include <features.h>
  23.  
  24.  
  25. /* Get types, macros, constants and function declarations
  26.    for all Mach microkernel interaction.  */
  27. #include <mach.h>
  28. #include <mach/mig_errors.h>
  29.  
  30. /* Get types and constants necessary for Hurd interfaces.  */
  31. #include <hurd/hurd_types.h>
  32.  
  33. /* Get MiG stub declarations for commonly used Hurd interfaces.  */
  34. #include <hurd/auth.h>
  35. #include <hurd/process.h>
  36. #include <hurd/fs.h>
  37. #include <hurd/io.h>
  38.  
  39. /* Get `struct hurd_port' and related definitions implementing lightweight
  40.    user references for ports.  These are used pervasively throughout the C
  41.    library; this is here to avoid putting it in nearly every source file.  */
  42. #include <hurd/port.h>
  43.  
  44. #include <errno.h>
  45. #define    __hurd_fail(err)    (errno = (err), -1)
  46.  
  47. /* Basic ports and info, initialized by startup.  */
  48.  
  49. extern struct hurd_port *_hurd_ports;
  50. extern unsigned int _hurd_nports;
  51. extern volatile mode_t _hurd_umask;
  52.  
  53. /* Shorthand macro for referencing _hurd_ports (see <hurd/port.h>).  */
  54.  
  55. #define    __USEPORT(which, expr) \
  56.   HURD_PORT_USE (&_hurd_ports[INIT_PORT_##which], (expr))
  57.  
  58.  
  59. /* Base address and size of the initial stack set up by the exec server.
  60.    If using cthreads, this stack is deallocated in startup.
  61.    Not locked.  */
  62.  
  63. extern vm_address_t _hurd_stack_base;
  64. extern vm_size_t _hurd_stack_size;
  65.  
  66. /* Initial file descriptor table we were passed at startup.  If we are
  67.    using a real dtable, these are turned into that and then cleared at
  68.    startup.  If not, these are never changed after startup.  Not locked.  */
  69.  
  70. extern mach_port_t *_hurd_init_dtable;
  71. extern mach_msg_type_number_t _hurd_init_dtablesize;
  72.  
  73. /* Miscellaneous library state.  */
  74.  
  75.  
  76. /* Current process IDs.  */
  77.  
  78. extern pid_t _hurd_pid, _hurd_ppid, _hurd_pgrp;
  79. extern int _hurd_orphaned;
  80. extern struct mutex _hurd_pid_lock; /* Locks above.  */
  81.  
  82. /* Unix `data break', for brk and sbrk.
  83.    If brk and sbrk are not used, this info will not be initialized or used.  */
  84.  
  85.  
  86. /* Data break.  This is what `sbrk (0)' returns.  */
  87.  
  88. extern vm_address_t _hurd_brk;
  89.  
  90. /* End of allocated space.  This is generally `round_page (_hurd_brk)'.  */
  91.  
  92. extern vm_address_t _hurd_data_end;
  93.  
  94. /* This mutex locks _hurd_brk and _hurd_data_end.  */
  95.  
  96. extern struct mutex _hurd_brk_lock;
  97.  
  98. /* Set the data break to NEWBRK; _hurd_brk_lock must
  99.    be held, and is released on return.  */
  100.  
  101. extern int _hurd_set_brk (vm_address_t newbrk);
  102.  
  103. #define __need_FILE
  104. #include <stdio.h>
  105.  
  106. /* Calls to get and set basic ports.  */
  107.  
  108. extern process_t getproc (void);
  109. extern file_t getccdir (void), getcwdir (void), getcrdir (void);
  110. extern auth_t getauth (void);
  111. extern int setproc (process_t);
  112. extern int setcwdir (file_t), setcrdir (file_t);
  113.  
  114. /* Does reauth with the proc server and fd io servers.  */
  115. extern int __setauth (auth_t), setauth (auth_t);
  116.  
  117.  
  118. /* Split FILE into a directory and a name within the directory.  Look up a
  119.    port for the directory and store it in *DIR; store in *NAME a pointer
  120.    into FILE where the name within directory begins.  The directory lookup
  121.    uses CRDIR for the root directory and CWDIR for the current directory.
  122.    Returns zero on success or an error code.  */
  123.  
  124. extern error_t __hurd_path_split (file_t crdir, file_t cwdir,
  125.                   const char *file,
  126.                   file_t *dir, char **name);
  127. extern error_t hurd_path_split (file_t crdir, file_t cwdir,
  128.                 const char *file,
  129.                 file_t *dir, char **name);
  130.  
  131. /* Open a port to FILE with the given FLAGS and MODE (see <fcntl.h>).
  132.    The file lookup uses CRDIR for the root directory and CWDIR for the
  133.    current directory.  If successful, returns zero and store the port
  134.    to FILE in *PORT; otherwise returns an error code. */
  135.  
  136. extern error_t __hurd_path_lookup (file_t crdir, file_t cwdir,
  137.                    const char *file,
  138.                    int flags, mode_t mode,
  139.                    file_t *port);
  140. extern error_t hurd_path_lookup (file_t crdir, file_t cwdir,
  141.                  const char *filename,
  142.                  int flags, mode_t mode,
  143.                  file_t *port);
  144.  
  145. /* Split FILE into a directory and a name within the directory.  The
  146.    directory lookup uses the current root and working directory.  If
  147.    successful, stores in *NAME a pointer into FILE where the name
  148.    within directory begins and returns a port to the directory;
  149.    otherwise sets `errno' and returns MACH_PORT_NULL.  */
  150.  
  151. extern file_t __path_split (const char *file, char **name);
  152. extern file_t path_split (const char *file, char **name);
  153.  
  154. /* Open a port to FILE with the given FLAGS and MODE (see <fcntl.h>).
  155.    The file lookup uses the current root and working directory.
  156.    Returns a port to the file if successful; otherwise sets `errno'
  157.    and returns MACH_PORT_NULL.  */
  158.  
  159. extern file_t __path_lookup (const char *file, int flags, mode_t mode);
  160. extern file_t path_lookup (const char *file, int flags, mode_t mode);
  161.  
  162.  
  163. /* Open a file descriptor on a port.  FLAGS are as for `open'.  */
  164.  
  165. extern int openport (io_t port, int flags);
  166.  
  167. /* Open a stream on a port.  MODE is as for `fopen'.
  168.    If successful, this consumes a user reference for PORT
  169.    (which will be deallocated on fclose).  */
  170.  
  171. extern FILE *fopenport (io_t port, const char *mode);
  172. extern FILE *__fopenport (io_t port, const char *mode);
  173.  
  174.  
  175. /* Execute a file, replacing TASK's current program image.  */
  176.  
  177. extern error_t _hurd_exec (task_t task,
  178.                file_t file,
  179.                char *const argv[],
  180.                char *const envp[]);
  181.  
  182.  
  183. /* Inform the proc server we have exitted with STATUS, and kill the
  184.    task thoroughly.  This function never returns, no matter what.  */
  185.  
  186. extern void _hurd_exit (int status) __attribute__ ((noreturn));
  187.  
  188.  
  189. /* Initialize the library data structures from the
  190.    ints and ports passed to us by the exec server.
  191.    Then vm_deallocate PORTARRAY and INTARRAY.  */
  192.  
  193. extern void _hurd_init (int flags, char **argv,
  194.             mach_port_t *portarray, size_t portarraysize,
  195.             int *intarray, size_t intarraysize);
  196.  
  197. /* Do startup handshaking with the proc server.  */
  198.  
  199. extern void _hurd_proc_init (char **argv);
  200.  
  201.  
  202. /* Return the socket server for sockaddr domain DOMAIN.  */
  203.  
  204. extern socket_t _hurd_socket_server (int domain);
  205.  
  206. /* Send a `sig_post' RPC to process number PID.  If PID is zero,
  207.    send the message to all processes in the current process's process group.
  208.    If PID is < -1, send SIG to all processes in process group - PID.
  209.    SIG and REFPORT are passed along in the request message.  */
  210.  
  211. extern error_t _hurd_sig_post (pid_t pid, int sig, mach_port_t refport);
  212.  
  213. /* Fetch the host privileged port and device master port from the proc
  214.    server.  They are fetched only once and then cached in the
  215.    variables below.  A special program that gets them from somewhere
  216.    other than the proc server (such as a bootstrap filesystem) can set
  217.    these variables to install the ports.  */
  218.  
  219. extern kern_return_t get_privileged_ports (host_priv_t *host_priv_ptr,
  220.                        device_t *device_master_ptr);
  221. extern mach_port_t _hurd_host_priv, _hurd_device_master;
  222.  
  223. /* Return the PID of the task whose control port is TASK.
  224.    On error, sets `errno' and returns -1.  */
  225.  
  226. extern pid_t __task2pid (task_t task), task2pid (task_t task);
  227.  
  228. /* Return the task control port of process PID.
  229.    On error, sets `errno' and returns MACH_PORT_NULL.  */
  230.  
  231. extern task_t __pid2task (pid_t pid), pid2task (pid_t pid);
  232.  
  233.  
  234. /* Return the io server port for file descriptor FD.
  235.    This adds a Mach user reference to the returned port.
  236.    On error, sets `errno' and returns MACH_PORT_NULL.  */
  237.  
  238. extern io_t __getdport (int fd), getdport (int fd);
  239.  
  240.  
  241. #endif    /* hurd.h */
  242.